package com.shuoyue.ycgk.ui.account;

import com.shuoyue.ycgk.base.BaseModel;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;

public interface SmsContract {

    interface View extends BaseView {
        void sendSuc(String phone);
    }

    class Presenter extends BasePresenter<View> {
        private Model model = new Model();

        public void sendSms(String phone) {
            apply(model.sendSms(phone))
                    .subscribe(new ApiSubscriber<Optional<String>>(mView, this,true) {
                        @Override
                        public void onNext(Optional<String> s) {
                            mView.sendSuc(phone);
                        }
                    });

        }

    }

    class Model extends BaseModel {
        public Observable<BaseResult<String>> sendSms(String phone) {
            return RetrofitClient.getInstance().getApi().smsSend(phone);
        }
    }

}
